<?php


namespace Campus\Controller;

use Think\Controller;

/**
 * Class IndexController
 * @package campus\Controller
 * @郑钟良
 */
class IndexController extends Controller
{
    public function _initialize()
    {
        $this->setTitle('校园');
    }

    public function index($page=1)
    {
        //推荐帮忙ids
        $recommendIds = D('CampusRecommend')->field('help_id')->select();
        $recommendIds = array_column($recommendIds, 'help_id');
        //校园成员ids
        $memberIds = D('AuthGroupAccess')->where(array('group_id' => 2))->field('uid')->select(); //group_id=2是校园用户组id
        $memberIds = array_column($memberIds, 'uid');
        $productList = D('Help/Help')->getHelpListByUids($memberIds,$page,$totalCount,$recommendIds);
        $this->assign('productionList',$productList);
        $this->assign('totalCount',$totalCount);
        $this->setTitle('校园作品页面');
        $this->display();
    }

    public function member($page=1)
    {
        //获取校园成员id
        $memberIds=D('AuthGroupAccess')->where(array('group_id'=>2))->field('uid')->select();//group_id=2是校园用户组id
        $memberIds=array_column($memberIds,'uid');
        if($memberIds){
            $model=D('Member');
            $map['status']=1;
            $map['last_login_time']=array('neq',0);
            $map['uid']=array('in',$memberIds);
            $memberList=$model->where($map)->order('is_recommend desc')->page($page,50)->field('uid')->select();
            foreach ($memberList as &$v) {
                $v = query_user(array('uid','avatar128', 'space_url', 'fans', 'nickname','doing','address','help_count','sex','rank_link','sentiment','rate','user_help_3'), $v['uid']);

                $v['verify_info']=verify_info($v['uid']);
            }
            unset($v);
            $totalCount=count($memberIds);
            $this->assign('memberList',$memberList);
            $this->assign('totalCount',$totalCount);
        }
        $this->setTitle('校园大神页面');
        $this->display();
    }
}